class GraphicsController < ApplicationController
  # GET /graphics/new
  def new
    @graphic = Graphic.new
    @page = Page.find(params[:page_id])
  end

  def create
    @graphic = Graphic.new(params[:graphic])
    
    if @graphic.save
      flash[:notice] = 'Graphic was successfully uploaded.'
			redirect_to :controller => @graphic.page.section.name, :action => :show, :id => @graphic.page
    else
      render :action => "new"
    end
  end

  def destroy
    @graphic = Graphic.find(params[:id])
    @graphic.destroy
    flash[:notice] = 'Graphic was deleted.'
		redirect_to :controller => @graphic.page.section.name, :action => :show, :id => @graphic.page
  end
end